<template>
    <div>
        <div class="container">
            <div class="handle-box">
                <el-input v-model="query.name" placeholder="请输入名称/联系人、电话" class="handle-input mr10"></el-input>
                <el-button type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
                <el-select v-model="query.address" placeholder="全部政府客户" class="handle-select mr10" style="margin-left:20px;">
                    <el-option key="2" label="全部政府客户" value="全部政府客户"></el-option>
                    <el-option key="1" label="已过期客户" value="已过期客户"></el-option>
                </el-select>
                共有政府客户<i class="reds">50</i>个，已到期客户<i class="reds">12</i>个
              
                <router-link to="/goverment/addgoverment"  ><el-button type="success" style="float:right;">新增客户</el-button></router-link>
            </div>
            <el-table
                :data="tableData"
                border
                class="table"
                ref="multipleTable"
                header-cell-class-name="table-header"
               
            >
                <!-- <el-table-column type="selection" width="55" align="center"></el-table-column> -->
                <el-table-column prop="name" label="客户名称"></el-table-column>
                <el-table-column prop="expiretime" label="开通时间"></el-table-column>
                <el-table-column prop="expiretimeEnd" label="到期时间"></el-table-column>
               
                <el-table-column prop="operateName" label="联系人"></el-table-column>
                <el-table-column prop="operatePhone" label="联系电话"></el-table-column>
                <el-table-column prop="remark" label="备注"></el-table-column>
                <el-table-column label="产品配置" align="center">
                    <template slot-scope="scope">
						<el-button
						    type="text"
						    icon="el-icon-view"
						    @click="handlepz(scope.$index, scope.row)"
						>配置</el-button>
                     <!--   <el-tag
                            :type="scope.row.state==='已配置'?'success':(scope.row.state==='未配置'?'danger':'')"
                        >{{scope.row.state}}</el-tag> -->
                    </template>
                </el-table-column>

                
                <el-table-column label="操作" width="180" align="center">
                    <template slot-scope="scope">
                        <el-button
                            type="text"
                            icon="el-icon-view"
                            @click="handleCheck(scope.$index, scope.row)"
                        >查看</el-button>
                        <el-button
                            type="text"
                            icon="el-icon-delete"
                            class="red"
                            @click="handleDelete(scope.$index, scope.row)"
                        >删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination">
                <el-pagination
                    background
                    layout="total, prev, pager, next"
                    :current-page="query.pageIndex"
                    :page-size="query.pageSize"
                    :total="pageTotal"
                    @current-change="handlePageChange"
                ></el-pagination>
            </div>
        </div>

   
    </div>
</template>

<script>
import {
        goverment_findByList,
        goverment_delete
    } from "@/request/api"
export default {
    name: 'basetable',
    data() {
        return {
            query: {
                address: '',
                name: '',
                pageIndex: 1,
                pageSize: 10
            },
            tableData: [],
            multipleSelection: [],
            delList: [],
            editVisible: false,
            pageTotal: 0, 
            form: {},
            idx: -1,
            id: -1
        };
    },
    created() {
     
        this.getshuju()
    },
    methods: {

         getshuju(){
            let data = {
                type:"2",
                page:this.query.pageIndex
            }
            goverment_findByList(data).then((res)=>{
                this.tableData = res.rows
                this.pageTotal = res.total ;
            })
          
        },
		handlepz(index,row){
			this.$router.push({
			    path:'/goverment/configuration',
			    query:{
			        id:row.id
			    }
			})
		},
        handleCheck(index, row){
            this.$router.push({
                path:'/goverment/checkgoverment',
                query:{
                    id:row.id
                }
            })
        },
        // 触发搜索按钮
        handleSearch() {
            this.getshuju()
        },
        // 删除操作
        handleDelete(index, row) {
            // 二次确认删除
            let id = row.id
            this.$confirm('确定要删除吗？', '提示', {
                type: 'warning'
            })
                .then(() => {
                    goverment_delete(id).then((res)=>{
                        this.$message.success('删除成功');
                        this.getshuju()
                    })
                   
                })
                .catch(() => {
                    
                });
        },
   
        // 分页导航
        handlePageChange(val) {
            this.$set(this.query, 'pageIndex', val);
            this.getshuju();
        },
       
    },
    
};
</script>

<style scoped>
.handle-box {
    margin-bottom: 20px;
}

.handle-select {
    width: 120px;
}

.handle-input {
    width: 300px;
    display: inline-block;
}
.table {
    width: 100%;
    font-size: 14px;
}
.red {
    color: #ff0000;
}
.mr10 {
    margin-right: 10px;
}
.table-td-thumb {
    display: block;
    margin: auto;
    width: 40px;
    height: 40px;
}
.reds{
    color: red;
}
</style>
